<?php
class Category_model extends CI_Model {
	function __construct() {
		parent::__construct();
	}
	
	// Lấy tất cả category
	function list_all($order_by = 'category_name', $order = 'ASC') {
		return $this->db->order_by($order_by, $order)
						->get('category')->result();
	}
	
	// Lấy category theo slug
	function get_by_slug($category_slug) {
		return $this->db->where('category_slug', $category_slug)
						->get('category')->row();
	}
	
	// Lấy category theo id
	function get_by_id($category_id) {
		return $this->db->where('id', $category_id)
						->get('category')->row();
	}
}